﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Rapid.ViewModel;

namespace Rapid
{
    public partial class UserControlPatientForm : UserControl
    {
        public UserControlPatientForm()
        {
            InitializeComponent();

            // will romve
            Setup.FirstRun();

            //rdoMonitoring.Checked = TestResults.isMonitoring;

            txtID.Text = PatientView.Id;
            txtFirstname.Text = PatientView.Firstname;
            txtAddress.Text = PatientView.Address;
            txtNote.Text = PatientView.Note;

            //lblID.Text = PatientView.getPatientID();
            //lblName.Text = PatientView.getFullname();

            lblPatientTitle1.Text = PatientTitleViewModel.GetPatientTitle1();
            lblPatientTitle2.Text = PatientTitleViewModel.GetPatientTitle2();
            lblPatientTitle3.Text = PatientTitleViewModel.GetPatientTitle3();
            lblPatientTitle4.Text = PatientTitleViewModel.GetPatientTitle4();
        }

        private void rdoMonitoring_CheckedChanged(object sender, EventArgs e)
        {
            //TestResults.isMonitoring = rdoMonitoring.Checked;
            Validatetion.IsModeValid(txtID.Text);
        }

        private void txtID_TextChanged(object sender, EventArgs e)
        {
            int temp;
            if (string.IsNullOrEmpty(txtID.Text))
            {
                panelBellow.Location = new Point(6, 87);
                lblError.Text = "Required";
                lblError.Visible = true;
            }
            else if (!Int32.TryParse(txtID.Text, out temp))
            {
                panelBellow.Location = new Point(6, 87);
                lblError.Text = "ID must be is number";
                lblError.Visible = true;
            }
            else
            {
                lblError.Visible = false;
                panelBellow.Location = new Point(6, 75);
                PatientView.Id = txtID.Text;
            }

        }

        private void txtFirstname_TextChanged(object sender, EventArgs e)
        {
            PatientView.Firstname = txtFirstname.Text;
        }

        private void txtAddress_TextChanged(object sender, EventArgs e)
        {
            PatientView.Address = txtAddress.Text;
        }

        private void txtNote_TextChanged(object sender, EventArgs e)
        {
            PatientView.Note = txtNote.Text;
        }
    }
}
